function voutput(fvideo, fvideoout, fdata, nstart, nend,  bdrawellipse)

v = mmreader(fvideo);

load(fdata)

aviobj = avifile(fvideoout, 'fps', 30);


fig = figure;

r = 255;
g = 255;
b = 255;
linethickness = 3;


for i = nstart:nend 
    vindex = i+nprocessstart-1;   
    vindex
    img = read(v,vindex);
    img2 = img;
    
    imgsz = size(img);
    xl = imgsz(1);
    yl = imgsz(2);
    
    nobjs = objs(i);
        
    for j = 1:nobjs       
            if bdrawellipse == 1                                
                x0 = vex0s(i,j);
                y0 = vey0s(i,j);
                phi = vephis(i,j);
                a = veas(i,j);
                b = vebs(i,j);
                img2 = DrawImgEllipse(img2, x0, y0, a, b, phi);
            else
                x1 = vx1s(i,j);
                x2 = vx2s(i,j);
                y1 = vy1s(i,j);
                y2 = vy2s(i,j);
                img2 = DrawThickColorRGBBox(img2,  x1, y1, x2, y2, r, g, b, linethickness, xl, yl);
            end
    end
    
    imshow(img2)
    f = getframe(fig);
    aviobj = addframe(aviobj,f);  
end

aviobj = close(aviobj);
aviobj

close(fig)
